package org.sdp.pearproject.controller;


import org.sdp.pearproject.controller.custom.*;
import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;

import java.util.List;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName: MemberAccountController
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-27
 * @Version: 1.0
 * Table: pear_member_account
 * Comment:
 * 组织账号表
 */
@RestController
@RequestMapping(value = "/member_account")
public class MemberAccountController extends MemberAccountCustomController {
    static {
        addRequestClass("member_account", "add", "memberAccountController", MemberAccountController.class, MemberAccountAddRequest.class);
        addRequestClass("member_account", "add_encrypt", "memberAccountController", MemberAccountController.class, MemberAccountAddRequest.class);

        addRequestClass("member_account", "update", "memberAccountController", MemberAccountController.class, MemberAccountUpdateRequest.class);
        addRequestClass("member_account", "update_encrypt", "memberAccountController", MemberAccountController.class, MemberAccountUpdateRequest.class);

        addRequestClass("member_account", "delete", "memberAccountController", MemberAccountController.class, MemberAccountDeleteRequest.class);
        addRequestClass("member_account", "delete_encrypt", "memberAccountController", MemberAccountController.class, MemberAccountDeleteRequest.class);

        addRequestClass("member_account", "query", "memberAccountController", MemberAccountController.class, MemberAccountQueryRequest.class);
        addRequestClass("member_account", "query_encrypt", "memberAccountController", MemberAccountController.class, MemberAccountQueryRequest.class);

        addRequestClass("member_account", "list", "memberAccountController", MemberAccountController.class, MemberAccountQueryRequest.class);
        addRequestClass("member_account", "list_encrypt", "memberAccountController", MemberAccountController.class, MemberAccountQueryRequest.class);

        addRequestClass("member_account", "count", "memberAccountController", MemberAccountController.class, MemberAccountQueryRequest.class);
        addRequestClass("member_account", "count_encrypt", "memberAccountController", MemberAccountController.class, MemberAccountQueryRequest.class);

        addRequestClass("member_account", "stat", "memberAccountController", MemberAccountController.class, MemberAccountQueryRequest.class);
        addRequestClass("member_account", "stat_encrypt", "memberAccountController", MemberAccountController.class, MemberAccountQueryRequest.class);

    }

    @PostMapping("/add")
    public Integer addMemberAccount(@MixRequestBody MemberAccountAddRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("member_account", "add", request, callFromEncrypt);
        return super.addMemberAccount(request);
    }

    @PostMapping("/add_encrypt")
    public String addMemberAccountEncrypt(@MixRequestBody String strRequest) throws Exception {
        MemberAccountAddRequest request = (MemberAccountAddRequest) super.decrypt("member_account", "add_encrypt", strRequest, MemberAccountAddRequest.class);
        Integer result = addMemberAccount(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/update")
    public Integer updateMemberAccount(@MixRequestBody MemberAccountUpdateRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("member_account", "update", request, callFromEncrypt);
        return super.updateMemberAccount(request);
    }

    @PostMapping("/update_encrypt")
    public String updateMemberAccountEncrypt(@MixRequestBody String strRequest) throws Exception {
        MemberAccountUpdateRequest request = (MemberAccountUpdateRequest) super.decrypt("member_account", "update_encrypt", strRequest, MemberAccountUpdateRequest.class);
        Integer result = updateMemberAccount(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/delete")
    public Integer deleteMemberAccount(@MixRequestBody MemberAccountDeleteRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("member_account", "delete", request, callFromEncrypt);
        return super.deleteMemberAccount(request);
    }

    @PostMapping("/delete_encrypt")
    public String deleteMemberAccountEncrypt(@MixRequestBody String strRequest) throws Exception {
        MemberAccountDeleteRequest request = (MemberAccountDeleteRequest) super.decrypt("member_account", "delete_encrypt", strRequest, MemberAccountDeleteRequest.class);
        Integer result = deleteMemberAccount(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/query")
    public MemberAccountQueryResponse queryMemberAccount(@MixRequestBody MemberAccountQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("member_account", "query", request, callFromEncrypt);
      return super.queryMemberAccount(request);
    }

    @PostMapping("/query_encrypt")
    public String queryMemberAccountEncrypt(@MixRequestBody String strRequest) throws Exception {
        MemberAccountQueryRequest request = (MemberAccountQueryRequest) super.decrypt("member_account", "query_encrypt", strRequest, MemberAccountQueryRequest.class);
        MemberAccountQueryResponse result = queryMemberAccount(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/list")
    public List<MemberAccountQueryResponse> listMemberAccount(@MixRequestBody MemberAccountQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("member_account", "list", request, callFromEncrypt);
        if (super.needTotal("member_account", "list", request)) {
            super.setTotal("member_account", "list", request, super.countMemberAccount(request));
        }
        return super.listMemberAccount(request);
    }

    @PostMapping("/list_encrypt")
    public String listMemberAccountEncrypt(@MixRequestBody String strRequest) throws Exception {
        MemberAccountQueryRequest request = (MemberAccountQueryRequest) super.decrypt("member_account", "list_encrypt", strRequest, MemberAccountQueryRequest.class);
        List<MemberAccountQueryResponse> result = listMemberAccount(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/count")
    public Integer countMemberAccount(@MixRequestBody MemberAccountQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("member_account", "count", request, callFromEncrypt);
      return super.countMemberAccount(request);
    }


    @PostMapping("/count_encrypt")
    public String countMemberAccountEncrypt(@MixRequestBody String strRequest) throws Exception {
        MemberAccountQueryRequest request = (MemberAccountQueryRequest) super.decrypt("member_account", "count_encrypt", strRequest, MemberAccountQueryRequest.class);
        Integer result = countMemberAccount(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/stat")
    public BaseStatResponse statMemberAccount(@MixRequestBody MemberAccountQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("member_account", "stat", request, callFromEncrypt);
        return super.statMemberAccount(request);
    }

    @PostMapping("/stat_encrypt")
    public String statMemberAccountEncrypt(@MixRequestBody String strRequest) throws Exception {
        MemberAccountQueryRequest request = (MemberAccountQueryRequest) super.decrypt("member_account", "stat_encrypt", strRequest, MemberAccountQueryRequest.class);
        BaseStatResponse result = statMemberAccount(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }


}
